package com.sc.VenusQueryBeta.ui.fragments.home.child.tabs;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.view.View;
import android.widget.GridView;

import com.hengjun.kingstar.sdk.base.BasePresenter;
import com.hengjun.kingstar.sdk.base.fragment.BaseMVPCompatFragment;
import com.sc.VenusQueryBeta.R;
import com.sc.VenusQueryBeta.adapter.home.GridViewAdapter;
import com.sc.VenusQueryBeta.constant.Constants;
import com.sc.VenusQueryBeta.contract.home.tabs.GuiBInContract;
import com.sc.VenusQueryBeta.model.bean.home.VipListBean;
import com.sc.VenusQueryBeta.presenter.home.tabs.GuiBInPresenter;
import com.sc.VenusQueryBeta.ui.activites.HotelActivity;
import com.sc.VenusQueryBeta.ui.activites.OverSeasActivity;

import java.util.List;

import butterknife.BindView;

/**
 * Created by SC-02 on 2018/9/19.
 * 贵宾厅fragment
 */

public class GuiBinFragment extends BaseMVPCompatFragment<GuiBInContract.GuiBInPresenter> implements GuiBInContract.IGuiBInView {


    @BindView(R.id.rv_ao)
    GridView rvAo;
    @BindView(R.id.rv_haiwai)
    GridView rvHaiwai;

    @Override
    public void initData() {
        super.initData();
//        showProgressDialog("正在加载");
//        mPresenter.getVipListData(1);
//        mPresenter.getVipListData1(2);
    }

    public static GuiBinFragment newInstance() {
        return new GuiBinFragment();
    }

    @NonNull
    @Override
    public BasePresenter initPresenter() {
        return GuiBInPresenter.newInstance();
    }




    @Override
    public void updateContentList(List<Object> list) {

    }

    @Override
    public void itemNotifyChanged(int position) {

    }

    @Override
    public void showVipListDataSuccess(final VipListBean vipListBean) {
        GridViewAdapter gridViewAdapter = new GridViewAdapter(mActivity, vipListBean);
        rvAo.setAdapter(gridViewAdapter);
        gridViewAdapter.setClickListener(new GridViewAdapter.ClickListener() {
            @Override
            public void click(VipListBean.DataBean.ClubListBean clubListBean,int position) {
                    Intent intent = new Intent(mActivity, HotelActivity.class);
                    intent.putExtra(Constants.VIP_CLUB_LIST,clubListBean);
                    startActivity(intent);
            }
        });
        hideProgressDialog();

    }

    @Override
    public void showVipListDataSuccess1(final VipListBean vipListBean) {
        GridViewAdapter gridViewAdapter1 = new GridViewAdapter(mActivity, vipListBean);
        rvHaiwai.setAdapter(gridViewAdapter1);

        gridViewAdapter1.setClickListener(new GridViewAdapter.ClickListener() {
            @Override
            public void click(VipListBean.DataBean.ClubListBean clubListBean,int position) {
                if (vipListBean.getData().get(0).getDetailShowType()== 1){
                    Intent intent = new Intent(mActivity, HotelActivity.class);
                    intent.putExtra(Constants.VIP_CLUB_LIST,clubListBean);
                    startActivity(intent);
//                    int detailShowType = vipListBean.getData().get(position).getDetailShowType();
//                    ToastUtils.showToast("detailShowType=="+detailShowType);
                }else {
                    Intent intent = new Intent(mActivity, OverSeasActivity.class);
                    intent.putExtra(Constants.VIP_CLUB_LIST,clubListBean);
                    startActivity(intent);
//                    int detailShowType = vipListBean.getData().get(position).getDetailShowType();
//                    ToastUtils.showToast("detailShowType=="+detailShowType);
                }


            }
        });
        hideProgressDialog();

    }

    @Override
    public void showNetworkError() {
        hideProgressDialog();
    }

    @Override
    public void showLoadMoreError() {
        hideProgressDialog();

    }

    @Override
    public void showNoMoreData() {
        hideProgressDialog();

    }


    @Override
    public int getLayoutId() {
        return R.layout.fragment_guibin;
    }

    @Override
    public void initUI(View view, @Nullable Bundle savedInstanceState) {


    }

    @Override
    public void onLazyInitView(@Nullable Bundle savedInstanceState) {
        super.onLazyInitView(savedInstanceState);
        showProgressDialog("正在加载");
        mPresenter.getVipListData(1);
        mPresenter.getVipListData1(2);
    }



}
